<?php
require_once 'Pessoa.php';
/**
 * Description of Cliente
 *
 * @author silvio
 */
class Cliente extends Pessoa {
   
    private $newsenha;

    public function setNovaSenha($newsenha) {
        $this->newsenha = $newsenha;
    }

    public function getNovaSenha() {
        return $this->newsenha;
    }

    function validaCpf($cpf) {
        $cpf = preg_replace("/[^0-9]/", "", $cpf);
        $digitoUm = 0;
        $digitoDois = 0;

        for ($i = 0, $x = 10; $i <= 8; $i++, $x--) {
            $digitoUm += $cpf[$i] * $x;
        }
        for ($i = 0, $x = 11; $i <= 9; $i++, $x--) {
            if (str_repeat($i, 11) == $cpf) {
                return false;
            }
            $digitoDois += $cpf[$i] * $x;
        }

        $calculoUm = (($digitoUm % 11) < 2) ? 0 : 11 - ($digitoUm % 11);
        $calculoDois = (($digitoDois % 11) < 2) ? 0 : 11 - ($digitoDois % 11);
        if ($calculoUm <> $cpf[9] || $calculoDois <> $cpf[10]) {
            return false;
        }
        return true;
    }

    function randomsenha($limite) {
        $str = "abcdefghijklmnopqrstuvxwyzABCDEFGHIJKLMNOPQRSTUVXWYZ1234567890";
        $maximo = strlen($str) - 1;
        $ret = '';
        for ($i = 0; $i < $limite; $i++) {
            $ret .= $str{mt_rand(0, $maximo)};
        }
        return $ret;
    }

}

?>
